package it.polimi.traveldream.ejbclient.dtos;

import it.polimi.traveldream.utils.enums.PackageType;



import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TravelPackageDTO implements Serializable{
	private static final long serialVersionUID = -5033047052779523656L;
	private int id;
	private BigDecimal basePrice;
	private BigDecimal totalPrice;
	private String description;
	private Date endTrip;
	private Date expiry;
	private int feasibleReservations;
	private boolean overpast;
	private Date startTrip;
	private PackageType type;
	private List<ExcursionDTO> excursions;
	private List<HotelDTO> hotels;
	private List<TransportDTO> transports;
	private Timestamp timestampComposition;
	private UserDTO adderEmployee;
	
	public TravelPackageDTO() {
		super();
	}

	public TravelPackageDTO(int id, BigDecimal basePrice, BigDecimal totalPrice,
			String description, Date endTrip, Date expiry, int feasibleReservations,
			boolean overpast, Date startTrip, PackageType type,
			List<ExcursionDTO> excursions, List<HotelDTO> hotels,
			List<TransportDTO> transports) {
		super();
		this.id = id;
		this.basePrice = basePrice;
		this.totalPrice = totalPrice;
		this.description = description;
		this.endTrip = endTrip;
		this.expiry = expiry;
		this.feasibleReservations = feasibleReservations;
		this.overpast = overpast;
		this.startTrip = startTrip;
		this.type = type;
		this.initBaseProducts(hotels, transports, excursions);
	}

	private void initBaseProducts(List<HotelDTO> hotels,
			List<TransportDTO> transports, List<ExcursionDTO> excursions) {
		this.hotels = new ArrayList<HotelDTO>();
		this.transports = new ArrayList<TransportDTO>();
		this.excursions = new ArrayList<ExcursionDTO>();
		if(hotels != null) {
			this.hotels = hotels;
		}
		if(transports != null) {
			this.transports = transports;
		}
		if(excursions != null) {
			this.excursions = excursions;
		}
	}
	
	public void initBaseProductList() {
		hotels = new ArrayList<HotelDTO>();
		transports = new ArrayList<TransportDTO>();
		excursions = new ArrayList<ExcursionDTO>();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public BigDecimal getBasePrice() {
		return basePrice;
	}

	public void setBasePrice(BigDecimal basePrice) {
		this.basePrice = basePrice;
	}
	
	public BigDecimal getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getEndTrip() {
		return endTrip;
	}

	public void setEndTrip(Date endTrip) {
		this.endTrip = endTrip;
	}

	public Date getExpiry() {
		return expiry;
	}

	public void setExpiry(Date expiry) {
		this.expiry = expiry;
	}

	public int getFeasibleReservations() {
		return feasibleReservations;
	}

	public void setFeasibleReservations(int feasibleReservations) {
		this.feasibleReservations = feasibleReservations;
	}

	public boolean isOverpast() {
		return overpast;
	}

	public void setOverpast(boolean overpast) {
		this.overpast = overpast;
	}

	public Date getStartTrip() {
		return startTrip;
	}

	public void setStartTrip(Date startTrip) {
		this.startTrip = startTrip;
	}

	public PackageType getType() {
		return type;
	}

	public void setType(PackageType type) {
		this.type = type;
	}

	public List<ExcursionDTO> getExcursions() {
		return excursions;
	}

	public void setExcursions(List<ExcursionDTO> excursions) {
		this.excursions = excursions;
	}
	
	public void addExcursion(ExcursionDTO excursion) {
		this.excursions.add(excursion);
	}

	public void removeExcursion(ExcursionDTO excursion) {
		this.excursions.remove(excursion);
	}
	
	public List<HotelDTO> getHotels() {
		return hotels;
	}

	public void setHotels(List<HotelDTO> hotels) {
		this.hotels = hotels;
	}
	
	public void addHotel(HotelDTO hotel) {
		this.hotels.add(hotel);
	}
	
	public void removeHotel(HotelDTO hotel) {
		this.hotels.remove(hotel);
	}

	public List<TransportDTO> getTransports() {
		return transports;
	}

	public void setTransports(List<TransportDTO> transports) {
		this.transports = transports;
	}
	
	public void addTransport(TransportDTO transport) {
		this.transports.add(transport);
	}
	
	public void removeTransport(TransportDTO transport) {
		this.transports.remove(transport);
	}

	public Timestamp getTimestampComposition() {
		return timestampComposition;
	}

	public void setTimestampComposition(Timestamp timestampComposition) {
		this.timestampComposition = timestampComposition;
	}

	public UserDTO getAdderEmployee() {
		return adderEmployee;
	}

	public void setAdderEmployee(UserDTO adderEmployee) {
		this.adderEmployee = adderEmployee;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TravelPackageDTO other = (TravelPackageDTO) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
}
